<%@ include file="../common.jsp"%>

<script type="text/javascript">
	$(document).ready(
		function() {
			$("#userDetailsDTO").attr("action",'<c:url value="/submitUserDetailsAfterEditing.htm"></c:url>');
	});
</script>
 
 
<div>
	<form:form commandName="userDetailsDTO" id="userDetailsDTO">
			<form:hidden path="strCreatedAuthor" id="strCreatedAuthor"/>
			<form:hidden path="createdDate" id="createdDate"/>
			<form:hidden path="version" id="version"/>
<%-- 			<form:hidden path="role" id="role"/> --%>
			
			<c:forEach items="${userDetailsDTO.authorities}" var="roledetails" varStatus="index">
				<input type="hidden" name="role" value="${roledetails.roleId}" />
			</c:forEach>
			
					
		<div style="width: 70%;">
			<table class="adminFilterTable">
				<tr class="tableChildHeaderColor">
					<td colspan="5" align="center"><img alt="" src="./customTheme/Icons/BlueLotus_DMS_icons-37.png"> EDIT USER </td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr> 
					<td align="left" colspan="5" style="font-family: verdana; font-size: 12px;"> All fields are mandatory.</td> 
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> User ID </td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField"> <form:input path="username" id="userName" readonly="true"/> 
						 <form:errors path="username" cssClass="errorMsg" /> </td>
					<td class="spacingColumnWidthLess"></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> Name </td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField"> <form:input path="userDisplayName" id="userDisplayName"/> 
						<form:errors path="userDisplayName"  cssClass="errorMsg"/> </td>
					<td class="spacingColumnWidthLess"></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> Password </td>
					<td class="spacingColumnWidthLess"></td>
					<c:if test="${enablePasswordEdit eq 1}">
					<td class="formField"> <form:password path="password"/> 
						<form:errors path="password"  cssClass="errorMsg"/> </td>
					</c:if>
					<c:if test="${enablePasswordEdit eq 0}">
						<td class="formField"> <form:password path="password" readonly="true"/> 
						<form:errors path="password"  cssClass="errorMsg"/> </td>
					</c:if>
					<td class="spacingColumnWidthLess"></td>
					
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> EmailId </td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField"> <form:input path="emailId" id="strEmailId"/> 
						<form:errors path="emailId" cssClass="errorMsg" /> </td>
					<td class="spacingColumnWidthLess"></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> Company </td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField"> 
						<form:select path="cdId" id="companySelect" onchange="loadLocForComp(this.id,'locationSelect');">
								<form:option value="0">Choose Company</form:option>
							<c:forEach items="${companyMap}" var="companyMap">
								<form:option value="${companyMap.value.cdId}">${companyMap.value.cdName}</form:option>
							</c:forEach>
						</form:select>
						<form:errors path="cdId" cssClass="errorMsg" ></form:errors> </td>
					<td class="spacingColumnWidthLess"></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> Business Unit </td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField"> <form:select path="buId" id="locationSelect" onchange="loadDepttForBU(this.id,'department');">
							<form:option value="0">Choose Location</form:option>
							<c:forEach var="locationList" items="${locationList}">
								<form:option value="${locationList.ldId}">${locationList.ldName}</form:option>
							</c:forEach>
						</form:select>
						<form:errors path="buId" cssClass="errorMsg" />
					</td>
					<td class="spacingColumnWidthLess"></td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
				<tr>
					<td class="spacingColumnWidthLess"></td>
					<td class="formLabel"> Department </td>
					<td class="spacingColumnWidthLess"></td>
					<td class="formField"> <form:select path="deptId" id="department">
						 <form:option value="0">Choose Department</form:option>
							<c:forEach var="departmentMap" items="${departmentMap}">
								<form:option value="${departmentMap.key}">${departmentMap.value}</form:option>
							</c:forEach>
						 </form:select>
						 <form:errors path="deptId" cssClass="errorMsg" /> </td>
					<td class="spacingColumnWidthLess"></td>
				</tr>	
				<tr class="formSpacingRow"><td></td> </tr>
				<tr align="left">
					<td class="spacingColumnWidthLess"></td>
					<td></td>
					<td class="spacingColumnWidthLess"></td>
					<td colspan="2">
						<input class="formButton ui-corner-all" type="button" value="Update" onclick="javascript:addEntity('userDetailsDTO')"></input>
					</td>
				</tr>
				<tr class="formSpacingRow"><td></td> </tr>
			</table> 
		</div>
	</form:form>
	<br><br>
	<c:if test="${resultOfSave}">
		Operation Done Successfully.
	</c:if>
</div>